var express = require('express');
var router = express.Router();
var {commodityModel} = require('../../model/model')
/* GET home page. */
router.get('/', function(req, res, next) {
  res.render('index', { title: 'Express' });
});

router.post('/getlistrr',async(req,res)=>{
  console.log('111111');
  
  let {commodity_type} = req.body

  let data = await commodityModel.find({commodity_type:commodity_type})
  res.send({
    code:200,
    data:data
  })
})

router.post('/getshow',async(req,res)=>{
  
  
  let {_id} = req.body
  console.log(_id);
  let data = await commodityModel.find({_id})

  res.send({
    code:200,
    data:data
  })
})


router.post('/getshowrr',async(req,res)=>{
  // console.log(req.body);
  let {_id} = req.body
  // console.log(_id);
  let data = await commodityModel.find({_id:_id})
  // console.log(data);
  
  res.send({
    code:200,
    data:data
  })
})

router.get('/getlist',async(req,res)=>{
    let list = await commodityModel.find()
    res.send({
      code:200,
      data:list
    })
})
module.exports = router
